import 'dart:async';
import 'package:flutter_changdian_football/routers/app_routes.dart';
import 'package:get/get.dart';

class SplashController extends GetxController {

  @override
  void onInit() {
    super.onInit();

    countdown();
  }

  int time = 3;
  Timer? timer;

  /// 倒计时
  countdown() async {
    timer = Timer.periodic(const Duration(seconds: 1), (timer) { 
      time --;
      update();
      if (time < 1) {
        timer.cancel();
        Get.offNamed(AppRoutes.main);
      }
    });
  }

  jumpOver() {
    timer?.cancel();
    Get.offNamed(AppRoutes.main);
  }

}